﻿<ExpanderTreeView x:Class="WpfFileExplorer.Views.DriveStructureView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:uivm="clr-namespace:WpfFileExplorer"
             x:Name="this"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"             
             ItemsSource="{Binding ElementName=this, Path=TreeData}">
    <ExpanderTreeView.Resources>
        <HierarchicalDataTemplate DataType="{x:Type uivm:UITreeFolderViewModel}" ItemsSource="{Binding Path=Children}">
            <TextBlock Text="{Binding Path=Folder.Name}" />
        </HierarchicalDataTemplate>

        <DataTemplate DataType="{x:Type TreeViewItemViewModel}">
            <StackPanel Orientation="Horizontal">
                <Label Content="Waiting..." Foreground="DarkOrange" FontWeight="Bold" />
                <Grid Width="20" Height="20">
                    <Ellipse StrokeThickness="3" Stroke="DarkOrange" StrokeDashArray="1 1" RenderTransformOrigin="0.5,0.5">
                        <Ellipse.RenderTransform>
                            <RotateTransform Angle="0" />
                        </Ellipse.RenderTransform>
                        <Ellipse.Triggers>
                            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation RepeatBehavior="Forever" To="359" Duration="0:0:2" Storyboard.TargetProperty="RenderTransform.Angle" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </Ellipse.Triggers>
                    </Ellipse>
                </Grid>
            </StackPanel>
        </DataTemplate>
    </ExpanderTreeView.Resources>
    <ExpanderTreeView.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" IsItemsHost="true" />
        </ItemsPanelTemplate>
    </ExpanderTreeView.ItemsPanel>
    <ExpanderTreeView.ItemContainerStyle>
        <!-- This Style binds a TreeViewItem to a TreeViewItemViewModel. BasedOn="{StaticResource baseTVI}" -->
        <Style TargetType="{x:Type ExpanderTreeViewItem}" >
            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
            <Setter Property="ShowExpander" Value="{Binding ShowExpander, Mode=TwoWay}" />
        </Style>
    </ExpanderTreeView.ItemContainerStyle>
</ExpanderTreeView>
